<?php 
	session_start();
	$id_employee=$_SESSION['IDEmployee'];
	$id=$_GET['id'];
	include '../operations/connection.php';
	function getlang(){
		$lang = $_SESSION['lang'];
		
		if (empty($lang) || $lang == "EN") {
			$value = "../value/value_en.php";
		} else if($lang == "VN") {
			$value = "../value/value_vn.php";
		}
		else {
			$value = "../value/value_kr.php";
		}
		return $value;
	}
	$value = getlang();
	include($value);
	$lang = $_SESSION['lang'];
		//Get information of document
		
		$query = mysql_query("SELECT a.Tile,a.Content,e.Fullname,a.Timecreate,a.IDGroupApprove,a.comment,a.Location,a.EmployeePerforment, a.TripDate,a.TotalTime,a.Description,a.IDStatus,dl.DepartmentName
								FROM approvedoc a, employee e ,department_lang dl
								WHERE a.IDApproveDoc = '$id' AND a.IDEmployee = e.IDEmployee AND e.IDDepartment=dl.IDDepartment AND dl.LangID='$lang'");
		
		while ($row = mysql_fetch_array($query))
		{
			
			$dcomment = $row[comment];
			$dtitle = $row[Tile];
			$ddescription = $row[Description];
			$dtime = $row[Timecreate];
			$duser = $row[Fullname];
			$demployeeperforment = $row[EmployeePerforment];
			$dtripdate = $row[TripDate];
			$dlocation = $row[Location];
			$dtotaltime = $row[TotalTime];
			$didgroupapprover = $row[IDGroupApprove];
			$dcontent = $row[Content];
			$dstatus = $row[IDStatus];
			$dsDepartmentName=$row[DepartmentName];
		}
		
		$query1 = mysql_query("SELECT e.Fullname,dl.DepartmentName 
							   FROM listapprove l, employee e ,department_lang dl 
							   WHERE l.IDEmployee = e.IDEmployee AND e.IDDepartment= dl.IDDepartment AND dl.LangID='$lang' AND l.IDGroupApprove= '$didgroupapprover' ORDER BY l.Order ASC");
	
		
		
	?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$title?></title>

<link type="text/css" href="style/style.css" rel="stylesheet" />

</head>

<body onload="window.print();">
	
<div class="print_report">
    	<div style="float: left; width:350px; margin-top:50px"><span id="form-caption"><?=$l_business_trip_report?></span></div>
<div class="rcontent">
        	<table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse; float:left">
            	<tr>
                	<td width="40px" valign="middle" align="left">
                    	<img src="images/approver_en.png" alt="" />
                    </td>
                    <td>
                    	<ul class="list-approver" <?php if( mysql_num_rows( $query1)>=3){?> style="width: 320px" <?php }?> >
                    		<?php while ($row = mysql_fetch_array($query1)){
                    				$dnameapprover = $row[Fullname];
                    				$dnamedepartment = $row[DepartmentName];
                    		?>
							<li>
                            	<span class="approver-title"><?=$dnamedepartment?></span>
                            	<span class="approver-name"><?=$dnameapprover?></span>
                            	<span class="approver-signature"></span>
                            </li>
                           <?php }?>
                      </ul>
                    </td>
                </tr>
            </table>
        </div>
        <br style="clear:both" />
        <br />
        <table class="padd" width="100%" cellspacing="0" cellpadding="0">    
        	<tr>
            	<th align="left" width="15%"><?=$l_department?></th>				
				<td width="35%"><?=$dsDepartmentName?></td>
                <th align="left" width="15%"><?=$l_writer?></th>
              <td><?=$duser?></td>
        	</tr> 
            <tr>
            	<th align="left"><?=$l_created_date?></th>				
				<td><?=$dtime?></td>
                <th align="left"><?=$l_purchase_date?></th>
              <td><?=$dtime?></td>
        	</tr> 
            <tr>
            	<th align="left"><?=$l_employee_performent?></th>				
				<td><?=$demployeeperforment?></td>
                <th align="left"><?=$l_trip_date?></th>
                <td><?=$dtripdate?></td>
        	</tr> 
            <tr>
            	<th align="left"><?=$l_location?></th>				
				<td><?=$dlocation?></td>
                <th align="left"><?=$l_total_time?></th>
              <td><?=$dtotaltime?></td>
        	</tr>    	
            <tr>
            	<th align="left"><?=$l_title?></th>
				<td colspan="3"><?=$dtitle?></td>
            </tr>
        	<tr>
                <th align="left"><?=$l_description?></th>
                <td colspan="3"><?=$ddescription?></td>
            </tr>
            
        </table>     
		<table class="padd" width="100%" cellspacing="0" cellpadding="0" border="1" style="border-collapse:collapse">
            <tr>
               	 	<th><?=$l_no?></th>
            		<th><?=$l_product_item?></th>
            		<th><?=$l_company_name?></th>
            		<th><?=$l_quantity?></th>
            		<th><?=$l_price?></th>
            		<th><?=$l_price_vat?></th>
            		<th><?=$l_total_amount?></th>
          </tr>
           <?
            	$querybuy = mysql_query("select * from buying_document where document_id = '$id'");
            	$dtotalamountt = 0;
            	$i=0;
            	while ($row = mysql_fetch_array($querybuy))
            	{
            		$i=$i+1;
            		$dproductitem = $row[name];
            		$dcompanyname = $row[company];
            		$dquantity = $row[amount];
            		$dprice = $row[price];
            		$dpricevat = $row[vat];
            		$dtotalamount = $row[total];
            		$dtotalamountt = $dtotalamount + $dtotalamountt;
            	?>
            	<tr>
            		<td><?=$i?></td>
            		<td><?=$dproductitem?></td>
            		<td><?=$dcompanyname?></td>
            		<td><?=$dquantity?></td>
            		<td><?=$dprice?></td>
            		<td><?=$dpricevat?></td>
            		<td style="text-align: right;padding-right: 4px;"><?=number_format($dtotalamount)?></td>
            	</tr>
            	<?
            	}
            	?>       
            <tr>
            	<th colspan="4"><?=$l_total_amount?></th>
                <td colspan="3"><div align="right"><b><?=number_format($dtotalamountt)?></b></div></td>
            </tr>
         </table>
         <table class="padd" width="100%" cellspacing="0" cellpadding="0">
        	<tr>
            	<th class="top" colspan="2"></th>
            </tr>
            <tr>
            	<th align="left" width="15%"><?=$l_content?></th>
				<td width="85%"><?=$dcontent?></td>
            </tr>
        	<tr>
                <th align="left" width="15%"><?=$l_comment?></th>
                <td width="85%"><?=$dcomment?></td>
            </tr>
           
        </table>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-top:16px">
            <tr>
            	<td align="left" width="50%">ELI_F_0740_05</td>
            	<td align="right" width="50%">ELISOFT.LD</td>
            </tr>
        </table>
    </div>
</body>
</html>
